package com.rainng.coursesystem.controller.student;

import com.rainng.coursesystem.config.themis.annotation.Student;
import com.rainng.coursesystem.controller.BaseController;
import com.rainng.coursesystem.model.bo.AnswerDTO;
import com.rainng.coursesystem.model.vo.response.ResultVO;
import com.rainng.coursesystem.service.HomeWorkService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@Student
@RequestMapping("/student/homework")
@RestController("student_homeworkController")
public class HomeworkController extends BaseController {
    private final HomeWorkService service;
    public HomeworkController(HomeWorkService service) {
        this.service = service;
    }
    @ApiOperation("获取未提交作业列表")
    @GetMapping("/no")
    public ResultVO getNoHomeWorkList(){
        return service.getNoHomeWorkList();
    }
    @ApiOperation("获取已提交作业列表")
    @GetMapping("/yes")
    public ResultVO getYesHomeworkList(){
        return service.getYesHomeWorkList();
    }
    @ApiOperation("通过id获取作业提交详情")
    @GetMapping("/answer/{id}")
    public ResultVO getAnswerById(@PathVariable Integer id){
        return service.getAnswerById(id);
    }
    @ApiOperation("学生提交作业")
    @PostMapping("/submit")
    public ResultVO submit(AnswerDTO answerDTO) throws IOException {
        return service.submit(answerDTO);
    }

}
